<template>
    <div class="">
        <div class="pr10">
            <div class="analyItem">
                <p class="analyItemTit tx-center">状态</p>
                <div class="analyItemCon">
                    <p>
                        <span class="cGreen" v-if="IntegralHandle.cur_stage ===0" >正常</span>
                        <span class="cOrange" v-else-if="IntegralHandle.cur_stage ===1" >异常</span>
                        <span style="color: #FF9900" v-else-if="IntegralHandle.cur_stage ===2" >问题</span>
                        <span class="cRed" v-else-if="IntegralHandle.cur_stage ===3" >整改</span>
                    </p>
                    <p class="fl">
                    <span class="circlemark circlemark-green" v-if="IntegralHandle.cur_stage ===0" >优</span>
                        <span class="circlemark circlemark-lightGreen" v-else-if="IntegralHandle.cur_stage ===1" >良</span>
                            <span class="circlemark circlemark-yellow" v-else-if="IntegralHandle.cur_stage ===2" >中</span>
                        <span class="circlemark circlemark-lightRed" v-else-if="IntegralHandle.cur_stage ===3" >差</span>
                    </p>
                                        <div class="fixedTrangle">
                        <span href="javascript:" class="fixedtips">
                            </span>
                             <div class="fixedtipscon pt10 pb10">
                                        <i>
                                        </i>
                                    <div>
                                        <div>
                                            <p>正常 状态优</p>
                                            <p>异常(第一次降级进入待培，消分后正常接单)状态良</p>
                                            <p>问题（第二次积分清零，降级）状态中</p>
                                            <p>整改（第三次积分清零，直接进入待离）状态差</p>
                                        </div>
                                  </div>
                            </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="thinScroll pr10" v-scrollHeight="100">
            <div class="analyItem">
                <p class="analyItemTit tx-center">积分</p>
                <div class="analyItemCon">
                    <p class="col-md-6">
                        <span>积分</span><i class="cRed"> {{60+toushu+dindanC+(JcountIntegral?JcountIntegral.deductFraction:0)+(TcountIntegral?TcountIntegral.deductFraction:0)+dindanH+xiangPinH+xiangPinC}}分</i>
                    </p>
                </div>
            </div>
            <!-- 普级 -->
                <router-link tag="div"  :to="routerPath('integralComplaints')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">投诉</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">奖励</span>
                            <span class="cRed">0分</span>
                        </p>
                          <p class="col-md-4">
                            <span class="cLightGray pr8">积分</span>
                            <span class="cRed">{{toushu}}分</span>
                        </p>
                          <p class="col-md-4">
                            <span class="cLightGray pr8">合计</span>
                            <span class="cRed">{{toushu}}分</span>
                        </p>
                    </div>
                </router-link>
                <router-link tag="div" :to="routerPath('integralRejecte')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">拒单</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">奖励</span>
                            <span class="cRed">0分</span>
                        </p>
                        <p class="col-md-4">
                            <span class="cLightGray pr8">积分</span>
                            <span class="cRed">{{JcountIntegral?(JcountIntegral.deductFraction):0}}分</span>
                        </p>
                          <p class="col-md-4">
                            <span class="cLightGray pr8">合计</span>
                            <span class="cRed">{{JcountIntegral?(JcountIntegral.deductFraction):0}}分</span>
                        </p>
                    </div>
                </router-link>
                <router-link tag="div" :to="routerPath('integralRefund')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">退单</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">奖励</span>
                            <span class="cRed">0分</span>
                        </p>
                        <p class="col-md-4">
                            <span class="cLightGray pr8">积分</span>
                            <span class="cRed">{{TcountIntegral?TcountIntegral.deductFraction:0}}分</span>
                        </p>
                           <p class="col-md-4">
                            <span class="cLightGray pr8">合计</span>
                            <span class="cRed">{{TcountIntegral?TcountIntegral.deductFraction:0}}分</span>
                        </p>
                    </div>
                </router-link>
                <router-link tag="div"  :to="routerPath('integralPenalty')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">管理</p>
                    <div class="analyItemCon">
                          <p class="col-md-4">
                            <span class="cLightGray pr8">奖励</span>
                            <span class="cRed">0分</span>
                        </p>
                        <p class="col-md-4">
                            <span class="cLightGray pr8">积分</span>
                            <span class="cRed">{{countIntegral?countIntegral.integtral:0}}分</span>
                        </p>
                            <p class="col-md-4">
                            <span class="cLightGray pr8">合计</span>
                            <span class="cRed">{{countIntegral?countIntegral.integtral:0}}分</span>
                        </p>
                    </div>
                </router-link>
                       <router-link tag="div"  :to="routerPath('integralOrder')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">订单评价</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">奖励</span>
                            <span class="cRed">{{dindanH}}分</span>
                        </p>
                        <p class="col-md-4">
                            <span class="cLightGray pr8">积分</span>
                            <span class="cRed">{{dindanC}}分</span>
                        </p>
                           <p class="col-md-4">
                            <span class="cLightGray pr8">合计</span>
                            <span class="cRed">{{dindanH+dindanC}}分</span>
                        </p>
                    </div>
                </router-link>
                        <router-link tag="div"  :to="routerPath('integralProject')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">项目评价</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">奖励</span>
                            <span class="cRed">{{xiangPinH}}分</span>
                        </p>
                        <p class="col-md-4">
                            <span class="cLightGray pr8">积分</span>
                            <span class="cRed">{{xiangPinC}}分</span>
                        </p>
                           <p class="col-md-4">
                            <span class="cLightGray pr8">合计</span>
                            <span class="cRed">{{xiangPinH+xiangPinC}}分</span>
                        </p>
                    </div>
                </router-link>
        </div>
        <div class="pr10">
            <router-link tag="div"  :to="routerPath('newIntegralCount')" class="analyItem anItemBor" active-class="anItemBor-active">
                <p class="analyItemTit tx-center">综合</p>
                <div class="analyItemCon">
                    <p class="col-md-4">
                        <span>奖励</span>
                           <span>{{dindanH+xiangPinH}}分</span>
                    </p>
                    <p class="col-md-4">
                        <span>积分</span>
                        <span>{{xiangPinC+toushu+dindanC+(JcountIntegral?JcountIntegral.deductFraction:0)+(TcountIntegral?TcountIntegral.deductFraction:0)}}分</span>
                    </p>
                    <p class="col-md-4">
                        <span>合计</span>
                        <span>{{toushu+dindanC+(JcountIntegral?JcountIntegral.deductFraction:0)+(TcountIntegral?TcountIntegral.deductFraction:0)+dindanH+xiangPinH+xiangPinC}}分</span>
                    </p>
                    <!--                  <p class="col-md-4">
                                <span>{{integral.userLevel}}级降{{integral.nextLevel}} 级</span>
                            </p> -->
                    <!--                  <p class="col-md-4">
                                <span>{{integral.userLevel}}级降{{integral.nextLevel}} 级</span>
                            </p> -->
                </div>
            </router-link>
        </div>
    </div>

</template>
<script>
import { mapGetters } from 'vuex'
import { getIntegralMsg, fingCurStage, getIntegralStatus, PersonHandlerIntegralNum, countcomplaintsIntegral, getProblemIntegral, findNewIntegral } from '../Resources/Api'
export default {
    data () {
        return {
            integral: {},
            JcountIntegral: {},
            TcountIntegral: {},
            countIntegral: {},
            complaints: {},
            tIntegralObject: [],
            tIntegral: 0,
            flg: 1,
            tnewIntegral: {},
            dnewIntegral: {},
            xnewIntegral: {},
            toushu: 0,
            dindanH: 0,
            dindanC: 0,
            xiangPinH: 0,
            xiangPinC: 0,
            IntegralHandle: {}


        }
    },
    created () {
        this.GetIntegral()
        this.GetJCountIntegral()
        this.GetTCountIntegral()
        this.countHandlerIntegral()
        this.countComplaints()
        // this.ProblemIntegral()
        this.getNewIntegral()
        this.getDNewIntegral()
        this.getXNewIntegral()
        this.GetCurStage()
    },
    methods: {
        change (val) {
            this.flg = val
        },
        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        GetCurStage () {
            let _this = this
            _this.IntegralHandle = {}
            fingCurStage({
                uid: _this.leftInfo.uid
            }).then(results => {
                _this.IntegralHandle = results.data.Body
                if (_this.rejectUser == null) {
                    _this.rejectUser = {}
                }
            }).catch(error => {
                console.log(error)
            })
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        },
        // 投诉
        getNewIntegral () {
            let _this = this
            _this.tnewIntegral = {}
            findNewIntegral({
                type: 1,
                uid: this.leftInfo.uid
            }).then(result => {
                this.tnewIntegral = result.data.Body
                this.toushu = 0
                this.tnewIntegral.forEach(element => {
                    this.toushu += element.score
                })
            }).catch(err => {
                console.log(err)
            })
        },
        // 订单评价
        getDNewIntegral () {
            let _this = this
            _this.newIntegral = {}
            findNewIntegral({
                type: '2,3,4,5',
                uid: this.leftInfo.uid
            }).then(result => {
                this.dnewIntegral = result.data.Body
                this.dindanH = 0
                this.dindanC = 0
                this.dnewIntegral.forEach(element => {
                    if (element.subject === 1) {
                        this.dindanH += element.score
                        console.log(this.dindanH, '好')
                    } else {
                        this.dindanC += element.score
                        console.log(this.dindanC, '差')
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        },
        // 项目评价
        getXNewIntegral () {
            let _this = this
            _this.xnewIntegral = {}
            findNewIntegral({
                type: 6,
                uid: this.leftInfo.uid
            }).then(result => {
                this.xnewIntegral = result.data.Body
                this.xiangPinH = 0
                this.xiangPinC = 0
                this.xnewIntegral.forEach(element => {
                    if (element.subject === 1) {
                        this.xiangPinH += element.score
                        console.log(this.xiangPinH, '好')
                    } else {
                        this.xiangPinC += element.score
                        console.log(this.xiangPinC, '差')
                    }
                })
            }).catch(err => {
                console.log(err)
            })
        },
        GetIntegral () {
            let _this = this
            _this.integral = {}
            getIntegralMsg({
                uid: this.leftInfo.uid
            }).then(results => {
                this.integral = results.data.Body
            }).catch(err => {
                console.log(err)
            })
        },
        GetJCountIntegral () {
            let _this = this
            _this.JcountIntegral = {}
            getIntegralStatus({
                uid: this.leftInfo.uid,
                dataSource: 13
            }).then(results => {
                this.JcountIntegral = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        },

        GetTCountIntegral () {
            let _this = this
            _this.TcountIntegral = {}
            getIntegralStatus({
                uid: this.leftInfo.uid,
                dataSource: 14
            }).then(results => {
                this.TcountIntegral = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        },
        countHandlerIntegral () {
            let _this = this
            _this.countIntegral = {}
            PersonHandlerIntegralNum({
                userCard: this.leftInfo.app_cardNo
            }).then(results => {
                this.countIntegral = results.data.Body
            })
        },
        countComplaints () {
            let _this = this
            _this.complaints = {}
            countcomplaintsIntegral({
                uid: this.leftInfo.uid
            }).then(results => {
                this.complaints = results.data.Body
            })
        },
        ProblemIntegral () {
            let _this = this
            getProblemIntegral({
                pmId: this.leftInfo.uid
            }).then(result => {
                _this.tIntegralObject = result.data.Body.problemIntegralList
                _this.tIntegral = result.data.Body.problemIntegralList.map(list => list.integral).reduce((acc, cur) => (parseFloat(cur) + acc), 0)
            }).catch(err => {
                console.log(err)
            })
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    },
    watch: {
        leftInfo () {
            this.GetIntegral()
            this.GetJCountIntegral()
            this.GetTCountIntegral()
            this.countHandlerIntegral()
            this.countComplaints()
            this.getNewIntegral()
            this.getDNewIntegral()
            this.getXNewIntegral()
            this.GetCurStage()
        }
        // $route () {
        //     this.change()
        // }
    }
}

</script>
<style scoped>
.bgcolor {
  color: #fff;
  background-color: #409eff;
}
</style>
